package de.karlNet.login.attributeMapper;

import java.util.List;

import javax.naming.NamingException;
import javax.naming.directory.Attributes;

import de.karlNet.sambamanager.ldapModel.LdapObject;

public abstract class LdapObjectExtractor {
	protected String tryToGetString(String attributeName, Attributes attributes)
			throws NamingException {
		return this.tryToGetString(attributeName, attributes, "");
	}

	protected String tryToGetString(String attributeName, Attributes attributes,
			Object onDefault) throws NamingException {
		if (attributes.get(attributeName) == null) {
			return (String) onDefault;
		}
		return (String) attributes.get(attributeName).get();
	}

	public abstract LdapObject extract(Attributes attributes,
			List<String> objectClasses) throws NamingException;
}
